#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
struct student {
	char name[20];
	double MATH_score;
};
int main(int argc, char *argv[]) {
	struct student s[1000];
	int n;//学生数量
	printf("请输入学生总数：\n");
	scanf("%d",&n);
	int i,j,temp,str;
	for(i=0;i<n;i++){
		printf("请输入学生姓名、数学成绩：\n");
		scanf("%s %lf",s[i].name,&s[i].MATH_score);
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<(n-1)-i;j++){
			if(s[j].MATH_score<s[j+1].MATH_score){
				char str[20];//用于交换字符串数值
				temp=s[j].MATH_score;
				s[j].MATH_score=s[j+1].MATH_score;
				s[j+1].MATH_score=temp;
				strcpy(str,s[j+1].name);
				strcpy(s[j+1].name,s[j].name);
				strcpy(s[j].name,str);
			}
		}
	}
	printf("按照从高到低成绩排序：\n");
	for (i=0;i<n;i++){
		printf("%s\n",s[i].name);
		printf("%lf\n",s[i].MATH_score);
	}
	return 0;
}